<extend name="Layout:layout"/>

<block name="css">
    <link rel="stylesheet" href=""></block>

<block name="srcjs">
    <script type="text/javascript" src=""></script>
</block>

<block name="content">

    <h1>用户列表</h1>
    <hr>
    <table id="usersListTable" class="table table-hover table-condensed">
        <thead>
            <tr>
                <th>编号</th>
                <th>登录名</th>
                <th>真实姓名</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>

            <tr>
                <td>1</td>
                <td>{$admin.username}</td>
                <td></td>
                <td></td>
            </tr>

        <volist name="users" id="user" key="k">
            <tr>
                <td>{$k+1}</td>
                <td>{$user.username}</td>
                <td></td>
                <td>
                    <if condition=" $_SESSION['current_user']['group_id'] == 1 ">
                        <button type="button" class="btn btn-danger btn-sm" data-id="{$user.id}">删除</button>
                    </if>
                </td>
            </tr>
        </volist>

        </tbody>
    </table>

    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>

    <br>
    <br>
    <br>
    <br>

    <br>
    <br>
    <br>
    <br>

    <br></block>

<block name="customjs">

    <script type="text/javascript">
        $(function () {

            $("#usersListTable").delegate("button", "click", function () {
                
                
                if(!confirm("是否要删除？")){
                    return;
                }
                
                var id = $(this).attr("data-id");
                //console.log(id);

                var sendData = {
                    "id": id
                };

                $.post("{:U('delUser')}", sendData).done(function (responseData) {
                    if (responseData.status == 1) {
                        alert(responseData.info);
                        location.href = responseData.jumpUrl;
                    } else {
                        alert(responseData.info);
                    }
                });

            });

        });
    </script>

</block>